Produce deprecated property in JsonSchema for obsolete types#130665
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the System.Text.Json JSON Schema exporter to emit the JSON Schema deprecated keyword when exporting schemas for [Obsolete] .NET types, and adds a regression test covering the new behavior.
Changes:
- Detect
[Obsolete]on exported types and setdeprecated: truein the generated schema. - Add
Deprecatedsupport to the internalJsonSchemamodel and include it in JSON output. - Add a unit test validating
deprecatedis emitted for an obsolete type.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/libraries/System.Text.Json/tests/Common/JsonSchemaExporterTests.cs | Adds a test case validating deprecated is produced for an [Obsolete] type. |
| src/libraries/System.Text.Json/src/System/Text/Json/Schema/JsonSchemaExporter.cs | Marks exported schemas as deprecated when the associated .NET type has [Obsolete]. |
| src/libraries/System.Text.Json/src/System/Text/Json/Schema/JsonSchema.cs | Adds a Deprecated keyword to the schema model, counts it, and emits it during JSON serialization. |
2e895bf to
a5d6c2d
Compare
a5d6c2d to
0460d8b
Compare
|
Tagging subscribers to this area: @dotnet/area-system-text-json |
0460d8b to
76a2de7
Compare
|
@copilot |
... Investigated this failure in detail:
Given current evidence, this looks more like a transient/leg-specific failure than a deterministic regression from this PR. If it reappears on rerun, we should escalate to deeper x86-specific investigation. Note This comment was generated with AI/Copilot assistance. |
Spec: https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-9.3